# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=shadowfinder
pkgver=0.6.1.r0.gcccdd8c
pkgrel=1
pkgdesc='Find possible locations of shadows around the world.'
arch=('any')
groups=('blackarch' 'blackarch-misc')
url='https://github.com/bellingcat/ShadowFinder'
license=('MIT')
depends=('python' 'python-basemap' 'python-matplotlib' 'python-fire'
         'python-numpy' 'python-pandas' 'python-pytz' 'python-suncalc'
         'python-timezonefinder')
makedepends=('git' 'python-build' 'python-pip')
options=(!emptydirs)
source=("git+https://github.com/bellingcat/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

prepare() {
  cd $pkgname

  sed -i 's|python =  ">=3.9,<3.13"|python = ">=3.9"|g' pyproject.toml
}

build() {
  cd $pkgname

  python -m build --wheel --outdir="$startdir/dist"
}

package() {
  cd $pkgname

  pip install \
    --verbose \
    --disable-pip-version-check \
    --no-warn-script-location \
    --ignore-installed \
    --no-compile \
    --no-deps \
    --root="$pkgdir" \
    --prefix=/usr \
    --no-index \
    --find-links="file://$startdir/dist" \
    $pkgname
}

